<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="s" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="sf" uri="http://www.springframework.org/tags/form" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<base href="<%=basePath%>">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>后台管理系统-病例管理</title>

<link rel="stylesheet" type="text/css" href="resources/css/medical_case.css">
<%@ include  file="../includes/icon.html" %>
</head>
<body>

   <div class="headbar">
        
   </div>
   <div class="linkbar">
    <div>
        <span style="display:inline-block;width:80%;float:left;color:white;line-height:40px;">
            <a class="linkbar_a" href="admin/searchHealthUser">数据手工录入</a> | <a class="linkbar_a" href="admin/queryAutoInput">数据自动录入</a> 
        </span>
        <span style="display:inline-block;width:20%;float:right;color:white;line-height:40px;">
            <a class="linkbar_a" href="doctor/diagnoseBrainTumour" style="float:right;padding-right:30px">在线诊断</a>
        </span>
       </div> 
   </div>
   <div class="body">
       
         <table class="body">
           <tr>
              <td class="nav_list"  valign="top">
                <div> 
                   <dl class="nav_list">
                       <dd class="no-selected" ><a href="admin/searchHealthUser">病人信息</a></dd>
                      <dd class="selected" ><a href="admin/queryMedicalCase">疾病实例</a></dd>
                      <dd class="no-selected" ><a href="admin/queryTreatmentMethod">治疗方法</a></dd>
                      <dd class="no-selected" ><a href="admin/queryDesease">疾病表</a></dd>
                      <dd class="no-selected" ><a href="admin/queryFeature">特征表</a></dd>
                      <dd class="no-selected" ><a href="admin/queryLabSheet">化验单定义</a></dd>
                      <dd class="no-selected" ><a href="admin/queryLabSheetResult">化验单结果</a></dd>
                      <dd class="no-selected" ><a href="admin/queryMedicine">药物表</a></dd>
                      <dd class="no-selected" ><a href="admin/querySystemUser">系统用户</a></dd>
                      <dd class="no-selected" ><a href="admin/queryCity">城市表</a></dd>
                      <dd class="no-selected" ><a href="admin/queryOccupation">职业表</a></dd>
                      <dd class="no-selected" ><a href="admin/queryBodyPart">身体部位表</a></dd>
                   </dl>
                </div>
              </td>
              <td class="content" valign="top">
                  <div class="search_bar"> 
                    <sf:form action="admin/queryMedicalCase" method="POST" modelAttribute="condition"> 
                    <span class="search_condition">
                       <div style="width:100%;margin-left:30px;margin-top:30px;">
                           <font>身份证号： </font><sf:input path="health_user_id_number"  style="width:150px;" placeholder="输入身份证号码" id="condition_id_number" />
                           <font> (用户查询请在【病人信息】栏里进行)</font>
                       </div>
                    </span>
                    <span class="search_button">
                         <input type="submit" class="search_button" value="查询">
                    </span>
                    </sf:form>
                  </div>
                  
                  
                  
                  <script language="javascript"> 
                    var isShown = false;
                    var needShown= ${isAddNewShow};
                    function clickAddDiv()
                    {
                    	if (isShown == false)
                    	{	
                    		showAddDiv();
                    		
                    	}
                    	else
                    	{
                    		hideAddDiv();
                    	}
                    }
					function showAddDiv() {

					  d=document.getElementById("add_new_medical_case");
					  d.style.display="inline-block";
					  
					  isShown =true;
					}
					function hideAddDiv() {

						  d=document.getElementById("add_new_medical_case");
						  d.style.display="none";
						  document.getElementById("error").style.display ="none";
						  isShown = false;
				    }
					
					
					/*重置，某个疾病的临床特征*/
					function resetClinicValue(clinicHiddenId, feature_id)
					{
						
						var featureCheckBoxId= clinicHiddenId+'_'+feature_id;
						 
						var featureCheckBoxStatus = document.getElementById(featureCheckBoxId).checked;
					//	alert(featureCheckBoxStatus);
						var currentHiddenValue = document.getElementById(clinicHiddenId).value;
					//	alert(currentHiddenValue);
						if(currentHiddenValue.length>0)
						{
							 currentHiddenValue = '|'+currentHiddenValue+'|';
						}
						else
						{
							currentHiddenValue = '|';
						}
					   
						if(featureCheckBoxStatus==true)
						{
							
							if(currentHiddenValue.indexOf('|'+feature_id+'|')<0)
							{
							//	alert(2);
								currentHiddenValue = currentHiddenValue+(feature_id+'|');
							}
						}
						else
						{
							
							if(currentHiddenValue.indexOf('|'+feature_id+'|')>=0)
							{
							//	alert(3);
								currentHiddenValue = currentHiddenValue.replace(feature_id+'|','');
							}
						}
						currentHiddenValue = currentHiddenValue.substring(1,currentHiddenValue.length-1);
						if(currentHiddenValue=='|')
							currentHiddenValue = '';
						document.getElementById(clinicHiddenId).value =currentHiddenValue;
					}
					
				 </script> 
                  
                  
                  <div class="status_bar">
                     <div style="display:block;float:left">搜索结果：</div>   <div class="add_new_button" onClick="clickAddDiv()" >添加+</div>
                  </div>
                  
                  <div class="add_new_health_user" id="add_new_medical_case">
                     <sf:form action="admin/addMedicalCase" method="POST" modelAttribute="new_medical_case"> 
                    <span class="add_new_health_user">
                       <div style="width:100%;margin-left:30px;margin-top:17px;">
                           <font>身份证号： </font><sf:input path="health_user_id_number"  style="width:150px;" placeholder="输入身份证号码"   />
                           <font>疾病： </font><sf:select path="desease_code"  style="width:124px;" placeholder="选择级别编号" >
                                                   <c:forEach var = "desease"   items= "${desease_list}">
                                                      <sf:option value="${desease.desease_code}">${desease.desease_name}</sf:option>
                                                   </c:forEach>
                                             </sf:select>
                           <font>发病日期：</font><sf:input path="occur_datetime_string"  style="width:120px;" placeholder="输入最早发病的日期"  />
                      	   <font>发现日期：</font><sf:input path="discover_datetime_string"  style="width:120px;" placeholder="输入发现日期"  />
                       </div>
                       <div  class = "error"  >
                          <div id="error">
                            <div class="id_number_error"><sf:errors path="health_user_id_number" cssClass="error_font" /></font></div>
                      	  </div>
                       </div>
                       <div style="width:100%;margin-left:30px;margin-top:2px;">
                           <font>治疗开始日期：</font><sf:input path="treatment_start_datetime_string"  style="width:120px;" placeholder="输入治疗开始日期"  />
                      	   <font>治疗结束日期：</font><sf:input path="treatment_end_datetime_string"  style="width:120px;" placeholder="输入治疗结束日期"  />
                       </div>
                       <div style="width:100%;margin-left:30px;margin-top:10px;">
                           <font>临床特征： 请在新添加的记录中编辑补充。</font>
		               </div>
		               <div style="width:100%;margin-left:30px;margin-top:10px;margin-bottom:5px;">
		                   <font>治疗方法：请在新添加的记录中编辑补充。 </font>
		               </div>
                    </span>
                    <span class="add_button">
                          <input type="submit" class="add_button" value="添加" />
                          <div class="add_button">
                              <font style="color:blue;font-size:15px;" onclick="hideAddDiv()" >取消</font>
                          </div>
                    </span>
                    </sf:form>
                  </div>
                  
                  <div class="information" id="information">
                     ${information} 
                  </div>
                  
                  
                  <div class="user_list">
                     <div class="row"> 
                         <span style="width:60px">序号</span>
                         <span style="width:60px">病例编号</span>
	                     <span style="width:80px">姓名</span>
	                     <span style="width:180px">身份证号</span>
	                     <span style="width:150px">疾病名称</span>
	                     <span style="width:90px">确诊日期</span>
	                     <span style="width:90px">病愈日期</span>
	                     <span style="width:100px">效果(10分制)</span>
	                     <span style="width:250px">操作</span>
                     </div>
                     
                      <script language="javascript">
			                    function clickEditDiv(id)
			                    {
			                    	if (document.getElementById("edit_medical_case"+id).style.display=='none')
			                    	{	
			                    		showEditDiv(id);
			                    	}
			                    	else
			                    	{
			                    		hideEditDiv(id);
			                    	}
			                    }
								function showEditDiv(id) {
			
								  d=document.getElementById("edit_medical_case"+id);
								  d.style.display="inline-block";
								  isShown =true;
								}
								function hideEditDiv(id) {
			
									  d=document.getElementById("edit_medical_case"+id);
									  d.style.display="none";
									  document.getElementById("error").style.display ="none";
									  isShown = false;
							    }
								
								function clickDetailDiv(id)
			                    {
			                    	if (document.getElementById("detail_medical_case"+id).style.display=='none')
			                    	{	
			                    		showDetailDiv(id);
			                    	}
			                    	else
			                    	{
			                    		hideDetailDiv(id);
			                    	}
			                    }
								function showDetailDiv(id) {
			
								  d=document.getElementById("detail_medical_case"+id);
								  d.style.display="inline-block";
								  isShown =true;
								}
								function hideDetailDiv(id) {
			
									  d=document.getElementById("detail_medical_case"+id);
									  d.style.display="none";
									  document.getElementById("error").style.display ="none";
									  isShown = false;
							    }
				           </script> 
                     
                     <c:forEach var = "medical_case_item"   items= "${medical_case_list}"  varStatus="xh">
                     
                         <div class="row">
							     <span style="width:60px">${xh.count}</span>
							     <span style="width:60px">${medical_case_item.medical_case_id}</span>
			                     <span style="width:80px">${medical_case_item.health_user_name}</span>
			                     <span style="width:180px">${medical_case_item.health_user_id_number}</span>
			                     <span style="width:150px">${medical_case_item.desease_name}</span>			                    
			                     <span style="width:90px">${medical_case_item.discover_datetime_string}</span>
			                     <span style="width:90px">${medical_case_item.treatment_end_datetime_string}</span>
			                     <span style="width:100px">${medical_case_item.effect_score}</span>
			                     <span style="width:250px">
			                        <a class="operation"  onClick="clickDetailDiv(${medical_case_item.medical_case_id})" >详情</a>
			                        <a class="operation"  onClick="clickEditDiv(${medical_case_item.medical_case_id})" >编辑</a>
			                        <a class="operation" href="admin/queryLabSheetResult?case_id=${medical_case_item.medical_case_id}">化验单</a>
			                        <a class="operation" href="admin/queryImage?case_id=${medical_case_item.medical_case_id}">影像管理</a>
			                     </span>  
                    	 </div>
                    	 
                    	 <div class="edit_health_user" id="edit_medical_case${medical_case_item.medical_case_id}" style="display:${medical_case_item.displayName}">
		                   <sf:form action="admin/editMedicalCase" method="POST" modelAttribute="edit_medical_case"> 
		                    <span class="add_new_health_user">
		                       <sf:input path="medical_case_id" type="hidden" value="${medical_case_item.medical_case_id}" />
		                       <div style="width:100%;margin-left:30px;margin-top:17px;">
		                               <font>病例编号：${medical_case_item.medical_case_id}</font>
			                           <font>身份证号： </font><sf:input path="health_user_id_number"  style="width:150px;" placeholder="输入身份证号码" value="${medical_case_item.health_user_id_number}"  />
			                           <font>疾病： </font><sf:select path="desease_code"  style="width:124px;" placeholder="选择级别编号" >
			                                                   <c:forEach var = "desease"   items= "${desease_list}">
			                                                      <c:if test="${medical_case_item.desease_code==desease.desease_code}">
			                                                         <sf:option selected="selected" value="${desease.desease_code}">${desease.desease_name}</sf:option>
			                                                      </c:if>
			                                                      <c:if test="${medical_case_item.desease_code!=desease.desease_code}">
			                                                         <sf:option value="${desease.desease_code}">${desease.desease_name}</sf:option>
			                                                      </c:if>
			                                                   </c:forEach>
			                                             </sf:select>
			                         </div>
			                       <div style="width:100%;margin-left:30px;margin-top:10px;">
			                            <font>发病日期：</font><sf:input path="occur_datetime_string"  style="width:100px;" placeholder="输入最早发病的日期" value="${medical_case_item.occur_datetime_string}" />
			                      	    <font>发现日期：</font><sf:input path="discover_datetime_string"  style="width:100px;" placeholder="输入发现日期" value="${medical_case_item.discover_datetime_string}" />
			                       </div>
													                      
			                      <div  class = "error"  >
			                         <div id="error">
			                          <div class="id_number_error"><sf:errors path="health_user_id_number" cssClass="error_font"  /></font></div>
			                      	 </div>
			                      </div>
			                      <div style="width:100%;margin-left:30px;margin-top:2px;">
			                           <font>治疗开始日期：</font><sf:input path="treatment_start_datetime_string"  style="width:120px;" placeholder="输入治疗开始日期" value="${medical_case_item.treatment_start_datetime_string}" />
			                      	   <font>治疗结束日期：</font><sf:input path="treatment_end_datetime_string"  style="width:120px;" placeholder="输入治疗结束日期"  value="${medical_case_item.treatment_end_datetime_string}" />
			                      </div>
			                      
			                      <div style="width:100%;margin-left:30px;margin-top:10px;">
			                           <font>临床特征： </font>  <br><sf:hidden path="clinic_feature"  style="width:150px;"  value="${medical_case_item.clinic_feature}"  id="clinic_${medical_case_item.medical_case_id}" />
				                       <c:forEach var = "clinic_item"   items= "${medical_case_item.potential_clinic_list}">
							                 <input type="checkbox"   ${clinic_item.checked} onclick="resetClinicValue('clinic_${medical_case_item.medical_case_id}','${clinic_item.feature_id}')"  id="clinic_${medical_case_item.medical_case_id}_${clinic_item.feature_id}">${clinic_item.feature_describe_note}</input>    <br>                   
							           </c:forEach>
					              </div>
					              <div style="width:100%;margin-left:30px;margin-top:10px;margin-bottom:5px;">
					                   <font>治疗方法： </font><sf:select path="treatment_method_id"  style="width:150px;"  id="treatment_method_${medical_case_item.medical_case_id}" >
					                                             <c:forEach var = "treatment"   items= "${medical_case_item.potential_treatment_method_list}">
			                                                      <c:if test="${treatment.treatment_method_def_id==medical_case_item.treatment_method_id}">
			                                                         <sf:option selected="selected" value="${treatment.treatment_method_def_id}">${treatment.method_name}</sf:option>
			                                                      </c:if>
			                                                      <c:if test="${treatment.treatment_method_def_id!=medical_case_item.treatment_method_id}">
			                                                         <sf:option value="${treatment.treatment_method_def_id}">${treatment.method_name}</sf:option>
			                                                      </c:if>
			                                                      
			                                                   </c:forEach>
					                                         </sf:select>
					              </div>
					               <div style="width:100%;margin-left:30px;margin-top:2px;">
			                           <font>治疗效果评定：</font><sf:input path="effect_score"  style="width:60px;"  value="${medical_case_item.effect_score}" /><font>分（满分10分）</font>
			                       </div>
					                       
		                    </span>
		                    <span class="add_button">
		                          <input type="submit" class="add_button" value="确认" />
		                          <div class="add_button">
		                              <font style="color:blue;font-size:15px;" onclick="hideEditDiv(${medical_case_item.medical_case_id})" >取消</font>
		                          </div>
		                    </span>
		                    </sf:form>
		                  </div>
		                  
		                  
		                  <div class="detail_health_user" id="detail_medical_case${medical_case_item.medical_case_id}" style="display:none">
		
		                    <span class="add_new_health_user">
		                    
		                          <div style="width:100%;margin-left:30px;margin-top:25px;">
		                               <font>病例编号：${medical_case_item.medical_case_id}</font>
		                               <font>身份证号： </font><span class="detail_text"  style="width:150px;"  >${medical_case_item.health_user_id_number}</span>
			                           <font>疾病： </font><span class="detail_text" style="width:124px;"   >${medical_case_item.desease_name}</span>                   
			                           <br><font>发病日期：</font><span class="detail_text"  style="width:120px;"    >${medical_case_item.occur_datetime_string}</span>
			                      	   <font>发现日期：</font><span class="detail_text"  style="width:120px;"   >${medical_case_item.discover_datetime_string}</span>
			                      </div>
			                    
			                      <div style="width:100%;margin-left:30px;margin-top:10px;">
			                           <font>治疗开始日期：</font><span class="detail_text"  style="width:120px;"   >${medical_case_item.treatment_start_datetime_string}</span>
			                      	   <font>治疗结束日期：</font><span class="detail_text"  style="width:120px;"   >${medical_case_item.treatment_end_datetime_string}</span>
			                      </div>
			                       <div style="width:100%;margin-left:30px;margin-top:10px;">
			                           <font>临床特征： </font>  <br>
			                             <c:forEach var = "clinic_item"   items= "${medical_case_item.potential_clinic_list}">
													      <span class="detail_text"  style="width:auto;margin-left:5px;"   >${clinic_item.feature_describe_note} </span>   <br> 
									    </c:forEach>
			               				                       
					              </div>
					              <div style="width:100%;margin-left:30px;margin-top:10px;margin-bottom:10px;">
					                   <font>治疗方法： </font> <span class="detail_text"  style="width:120px;"   >${medical_case_item.treatment_method_name}</span>
					              </div>
			                      
		                    </span>
		                    <span class="add_button">
		                          <input type="submit" class="add_button" onclick="hideDetailDiv(${medical_case_item.medical_case_id})" value="关闭" />
		                    </span>
		                    
		                  </div>
		                  
                     </c:forEach>
                     
                   
                    
                  </div>
              </td>
           </tr>
         </table>
       
   </div>
   <div class="bottom">
   			
   		
   	
   </div>
   
   
</body>
</html>